<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>分类树弹出窗口</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${global_templets_skin}/systemstyle/layui/css/layui.css" media="all">
    <link href="${global_templets_skin}/systemstyle/layui/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <script type="text/javascript" src="${global_templets_skin}/common/js/jquery.min.js"></script>
    <script type="text/javascript" src="${global_templets_skin}/systemstyle/layui/ztree/jquery.ztree.core-3.5.min.js"></script>
    <script type="text/javascript" src="${global_templets_skin}/systemstyle/layui/ztree/jquery.ztree.excheck-3.5.min.js"></script>
    <script type="text/javascript" src="${global_templets_skin}/systemstyle/layui/ztree/jquery.ztree.exhide.js"></script>
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 0 0 0;">
    <ul id="typeTree" class="ztree"></ul>
</div>

    <script src="${global_templets_skin}/systemstyle/layui/layui.js"></script>
<script>
    layui.config({
        base: '${global_templets_skin}/systemstyle/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set','form'], function () {
        var form   = layui.form;
        var $      = layui.jquery;
        var layer  = layui.layer;

        var setting = {
            view: {
                showIcon: true
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            /*点击事件*/
            callback: {
                onClick: zTreeOnClick
            }
        };

        $.ajax({
            url : '/admin/system_column/columnTree.do?siteId=${siteId!}',
            dataType : 'json',
            timeout : 1000,
            error : function(){
                alert("网络延时，请重试.");
            },
            success : function(res){
                treeNodes = res;
                let treeObj = $.fn.zTree.init($("#typeTree"), setting, treeNodes);
                treeObj.expandAll(true);
            }
        });

        function zTreeOnClick(e, treeId, treeNode) {
            //alert(treeNode.id + ", " + treeNode.name);
            parent.$('#columnform').val(treeNode.name);
            parent.$('#parentId').val(treeNode.id);
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        };
    });
</script>
</body>
</html>